import cv2
import matplotlib.pyplot as plt
import numpy as np


def show(img):
    cv2.imshow("img", img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

# 梯度=膨胀-腐蚀
pie = cv2.imread("./01_Picture/06_pie.png")
kernel = np.ones((7, 7), np.uint8)
dilate = cv2.dilate(pie, kernel, iterations=5)
erosion = cv2.erode(pie, kernel, iterations=5)
res = np.hstack((dilate, erosion))
show(res)

# 得到轮廓
gradient = cv2.morphologyEx(pie, cv2.MORPH_GRADIENT, kernel)
show(gradient)







